<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;
use App\Model\AdminLogsModel;
use App\Model\AdminNodeModel;

//后台模块表
class AdminTypeModel extends Model
{
    //定义一个表名
    protected $table = 'admin_type';
    //定义主键
    protected $primaryKey = 'id';

    //权限
    public function listAll()
    {
        $list = $this->orderBy('sort', 'asc')->get();
        foreach ($list as $k => $v) {
            $list[$k]['nodes'] = AdminNodeModel::where('type',$v['id'])->where('state',1)->orderBy('sort', 'asc')->get();
        }
        return $list;
    }
}
